

class Solution1 {
    public int findPeakElement(int[] nums) {
        int left=0,right=nums.length-1,mid;
        while(left<right){
            mid=(right-left+1)/2+left;
            if(nums[mid-1]<=nums[mid]) left=mid;
            else right=mid-1;
        }

        return right;
    }
}


class Solution {
    public int findMin(int[] nums) {
        int left=0,right=nums.length-1,mid;
        while(left<right){
            mid=(right-left)/2+left;
            if(nums[mid]>nums[right]) left=mid+1;
            else right=mid;
        }

        return nums[left];
    }
}